/*
*	File: BinaryFile.h
*	Date: 12/07/2011
*	Author: Ivan Gao
*	Desc:
*/
#ifndef BINARYFILE_H_
#define BINARYFILE_H_
#include <fstream>
#include "CommonDef.h"
using namespace std;
class SIMPLEANIMATION_API SBinaryFile
{
public:
	SBinaryFile () {}
	~SBinaryFile () {}
public:

	// Read from file.
	static bool ReadBytes (ifstream & file, char * pBuf, int nLen);
	static bool ReadInteger (ifstream & file, int & nValue);
	static bool ReadShort (ifstream & file, short & sValue);
	static bool ReadFloat (ifstream & file, float & fValue);
	static bool ReadDouble (ifstream & file, double & dValue);
	static bool ReadString (ifstream & file, string & str);

	// Read form a buffer
	static bool ReadBytes (const char * pInput, char * pBuf, int nLen);
	static bool ReadInteger (const char * pInput, int & nValue);
	static bool ReadShort (const char * pInput, short & sValue);
	static bool ReadFloat (const char * pInput, float & fValue);
	static bool ReadDouble (const char * pInput, double & dValue);
	static bool ReadString (const char * pInput, string & str);
	// Write to a file.
	static bool WriteBytes (ofstream & file, const char * pBuf, int nLen);
	static bool WriteShort (ofstream & file, const short sValue);
	static bool WriteInteger (ofstream & file, const int nValue);
	static bool WriteFloat (ofstream & file, const float fValue);
	static bool WriteDouble (ofstream & file, const double dValue);
	static bool WriteString (ofstream & file, const string & str);
private:
	SBinaryFile (SBinaryFile & file);
	SBinaryFile & operator = (const SBinaryFile & file);
};
#endif // BINARYFILE_H_